package com.digital.smartgrow.controller.business;

import com.digital.smartgrow.common.advice.Result;
import com.digital.smartgrow.common.util.WebTool;
import com.digital.smartgrow.entity.business.UpBase;
import com.digital.smartgrow.entity.datacenter.Teacher;
import com.digital.smartgrow.service.business.UpBaseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 申报分页信息 前端控制器
 * </p>
 *
 * @author sunyuechao
 * @since 2022-07-14
 */
@Api(tags = "申报信息")
@RestController
@RequestMapping("${context.prefix}/business/upBase")
public class UpBaseController {

    @Autowired
    private UpBaseService upBaseService;


//    @ApiOperation(value = "申报分页信息-分页查询")
//    @PostMapping("/list")
//    public Object getListByPage(@ApiParam @RequestBody UpBasePageDTO upBasePageDTO){
//        return upBaseService.getListByPage(upBasePageDTO);
//    }

    @ApiOperation(value = "申报分页信息-详情")
    @GetMapping("/{id}")
    public Object getInfo(@PathVariable Integer id){
        if (id == null) return Result.fail("id不能为空");
        return upBaseService.getInfo(id);
    }
//
//    @ApiOperation(value = "申报分页信息-删除")
//    @DeleteMapping("/{id}")
//    public Object removeById(@PathVariable Integer id){
//      if (id == null) return Result.fail("id不能为空");
//      return upBaseService.removeById(id);
//    }
    @ApiOperation(value = "申报分页信息-新增")
    @PostMapping()
    public Object add( @ApiParam @RequestBody UpBase upBase){
       return upBaseService.save(upBase);
    }

    @ApiOperation(value = "申报分页信息-编辑")
    @PutMapping()
    public Object edit(@ApiParam @RequestBody UpBase upBase){
    if (upBase==null||upBase.getId() == null)
       return Result.fail("id不能为空");
       return upBaseService.updateById(upBase);
    }
}
